from rest_framework.exceptions import NotFound
from rest_framework.response import Response
from rest_framework.views import exception_handler

def custom_exception_handler(exc, context):
    response = exception_handler(exc, context)
    
    if isinstance(exc, NotFound):
        return Response({'detail': '资源不存在'}, status=404)
    
    return response